package org.soc.timesheet.custom.domain.filters;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;

import org.soc.timesheet.domain.Projects;
import org.springframework.data.jpa.domain.Specification;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

@JsonAutoDetect(fieldVisibility=Visibility.ANY)
@JsonInclude(Include.NON_NULL)
public class ProjectFilter implements Specification<Projects> {
	
	private String descProject;

	public String getDescProject() {
		return descProject;
	}

	public void setDescProject(String descProject) {
		this.descProject = descProject;
	}

	@Override
	public Predicate toPredicate(Root<Projects> root, CriteriaQuery<?> query,
			CriteriaBuilder cb) {
		// TODO Auto-generated method stub
		Expression<String> exp =	root.<String>get("descProject");
		return cb.like(exp, descProject);
	}
	
	

	
}
